package com.rainy.micservice.provider.action;

import com.rainy.micservice.feignclient.DemoClient;
import com.rainy.micservice.provider.domain.App;
import com.rainy.micservice.provider.service.AppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DemoController implements DemoClient {

    @Autowired
    private AppService appService;

    @GetMapping("/demo/home")
    public String home() {

//        try {
//            //测试consumer熔断效果
//            Thread.sleep(1);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }finally {
//
//        }
        List<App> apps = appService.findAll();
        System.out.println("list size : " + apps.size());

//        App app = appService.findById();
//        System.out.println("find name : " + app.getName());

//        String sid = appService.insertApp("guoxiaolin");
//        System.out.println("insert sid ：" + sid);

//        boolean flag = appService.updateAppNameById("3","gxl");
//        System.out.println("update flag : " + flag);

//        boolean delflag = appService.delAppById("2");
//        System.out.println("delect flag : " + delflag);

        return "service处理完成。";

    }
}
